'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 抵抗
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');

/**
 * 获取抵抗属性
 * @param  {[type]} soldier_type [description]
 * @param  {[type]} soldier_lv   [description]
 * @return {[type]}              [description]
 */
exports.getAttr = function (resistance_conf_info) {
    if (!resistance_conf_info) {
        return [];
    }
    var resistance_list = [];
    if (resistance_conf_info.length <= 0) {
        return resistance_list;
    }
    var resistance_conf_list = resistance_conf_info.split(',');
    _.each(resistance_conf_list, function (resistance_conf) {
        var resistance_type = parseInt(resistance_conf.split(':')[0]);
        var resistance_value = parseInt(resistance_conf.split(':')[1]);
        if (!!resistance_type && !!resistance_value) {
            resistance_list.push({
                resistance_type: resistance_type,
                resistance_value: resistance_value
            });
        }
    });
    return resistance_list;
};
